@@ -37,8 +37,7 @@ module Agents |
||
37 | 37 |
def default_options |
38 | 38 |
{ "secret" => "supersecretstring", |
39 | 39 |
"expected_receive_period_in_days" => 1, |
40 |
- "payload_path" => "some_key", |
|
41 |
- "response" => "Event Created" |
|
40 |
+ "payload_path" => "some_key" |
|
42 | 41 |
} |
43 | 42 |
end |
44 | 43 |
|
@@ -30,7 +30,7 @@ describe Agents::WebhookAgent do |
||
30 | 30 |
expect(Event.last.payload).to eq({ 'name' => 'jon' }) |
31 | 31 |
end |
32 | 32 |
|
33 |
- it 'should not create event if secrets dont match' do |
|
33 |
+ it 'should not create event if secrets do not match' do |
|
34 | 34 |
out = nil |
35 | 35 |
expect { |
36 | 36 |
out = agent.receive_web_request({ 'secret' => 'bazbat', 'some_key' => payload }, "post", "text/html") |
@@ -39,17 +39,24 @@ describe Agents::WebhookAgent do |
||
39 | 39 |
end |
40 | 40 |
|
41 | 41 |
it 'should respond with customized response message if configured with `response` option' do |
42 |
- out = nil |
|
43 | 42 |
agent.options['response'] = 'That Worked' |
44 | 43 |
out = agent.receive_web_request({ 'secret' => 'foobar', 'some_key' => payload }, "post", "text/html") |
45 | 44 |
expect(out).to eq(['That Worked', 201]) |
45 |
+ |
|
46 |
+ # Empty string is a valid response |
|
47 |
+ agent.options['response'] = '' |
|
48 |
+ out = agent.receive_web_request({ 'secret' => 'foobar', 'some_key' => payload }, "post", "text/html") |
|
49 |
+ expect(out).to eq(['', 201]) |
|
46 | 50 |
end |
47 | 51 |
|
48 |
- it 'should respond with `Event Created` if response option is nil' do |
|
49 |
- out = nil |
|
52 |
+ it 'should respond with `Event Created` if the response option is nil or missing' do |
|
50 | 53 |
agent.options['response'] = nil |
51 | 54 |
out = agent.receive_web_request({ 'secret' => 'foobar', 'some_key' => payload }, "post", "text/html") |
52 | 55 |
expect(out).to eq(['Event Created', 201]) |
56 |
+ |
|
57 |
+ agent.options.delete('response') |
|
58 |
+ out = agent.receive_web_request({ 'secret' => 'foobar', 'some_key' => payload }, "post", "text/html") |
|
59 |
+ expect(out).to eq(['Event Created', 201]) |
|
53 | 60 |
end |
54 | 61 |
|
55 | 62 |
describe "receiving events" do |